home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / python2.4 / lib-old / newdir.pyc (.txt) < prev    next >
Python Compiled Bytecode  |  2005-10-18  |  2KB  |  74 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.4)
  3.  
  4.  
  5. def listattrs(x):
  6.     
  7.     try:
  8.         dictkeys = x.__dict__.keys()
  9.     except (AttributeError, TypeError):
  10.         dictkeys = []
  11.  
  12.     
  13.     try:
  14.         methods = x.__methods__
  15.     except (AttributeError, TypeError):
  16.         methods = []
  17.  
  18.     
  19.     try:
  20.         members = x.__members__
  21.     except (AttributeError, TypeError):
  22.         members = []
  23.  
  24.     
  25.     try:
  26.         the_class = x.__class__
  27.     except (AttributeError, TypeError):
  28.         the_class = None
  29.  
  30.     
  31.     try:
  32.         bases = x.__bases__
  33.     except (AttributeError, TypeError):
  34.         bases = ()
  35.  
  36.     total = dictkeys + methods + members
  37.     if the_class:
  38.         class_attrs = listattrs(the_class)
  39.         class_methods = []
  40.         for name in class_attrs:
  41.             if is_function(getattr(the_class, name)):
  42.                 class_methods.append(name)
  43.                 continue
  44.         
  45.         total = total + class_methods
  46.     elif bases:
  47.         for base in bases:
  48.             base_attrs = listattrs(base)
  49.             total = total + base_attrs
  50.         
  51.     
  52.     total.sort()
  53.     return total
  54.     i = 0
  55.     while i + 1 < len(total):
  56.         if total[i] == total[i + 1]:
  57.             del total[i + 1]
  58.             continue
  59.         i = i + 1
  60.     return total
  61.  
  62.  
  63. def is_function(x):
  64.     return type(x) == type(is_function)
  65.  
  66.  
  67. def dir(x = None):
  68.     if x is not None:
  69.         return listattrs(x)
  70.     else:
  71.         import __main__ as __main__
  72.         return listattrs(__main__)
  73.  
  74.